<?php
/**
 * This file is part of won-uploader.
 *
 * Author: Daniel K.
 *
 * won-uploader is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * won-uploader is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with won-uploader. If not, see <http://www.gnu.org/licenses/>.
 */
   
	if( !defined("won-uploader")) die();    // Silence is golden
	
	
   class User
   {
       protected /* string */  $username;
       protected /* string */  $email;
       protected /* int */     $id;
       protected /* boolean */ $admin;
       
       /**
        * Constructs a new object of <code>User</code>
        * @param    string      name    Name of the user
        * @param    string      email   User email
        * @param    int         id      User id
        * @param    UserState   state   State of the user
        * @see      Class UserState in UserState.lib.php
        */
       public function __construct($name, $email, $id, $adm)
       {
           if( $name == "" )
            throw new Exception("class User: name is empty");
           
           if( $email == "" )
            throw new Exception("class User: email is empty");
           
           if( ((int)$id) < 0 )
            throw new Exception("class User: invalid id");
           
           // Assign values
           $this->username = $name;
           $this->email    = $email;
           $this->id       = $id;
           $this->admin    = ( $adm === TRUE ? TRUE : FALSE) ;
       }
       
       /**
        * Returns the name of the user
        * @return   string  Name
        */
       public function getName()
       {
           return $this->username;
       }
       
       /**
        * Returns the email of the user
        * @return   string  Email
        */
       public function getEmail()
       {
           return $this->email;
       }
       
       /**
        * Returns the ID of the user
        * @return   int ID
        */
       public function getID()
       {
           return $this->id;
       }
       
       /**
        * Returns <code>TRUE</code> if the user is an admin
        * @return    boolean    Is admin?
        */
       public function isAdmin()
       {
           return $this->admin;
       }
       
   }
?>